package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Role;
import com.itheima.service.RoleService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("role")
public class RoleController {

    @Reference(version = "1.0")
    RoleService roleService;

    @PostMapping("findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        return roleService.findPage(queryPageBean);
    }

    @PostMapping("save")
    public Result save(@RequestBody Role role,Integer[] menuIds) {
        return roleService.save(role,menuIds);
    }

    @GetMapping("findById")
    public Result findById(Integer roleId) {
        return roleService.findById(roleId);
    }

    @GetMapping("delete")
    public Result delete(Integer roleId) {
        return roleService.delete(roleId);
    }

    @PostMapping("update")
    public Result update(@RequestBody Role role,Integer[] menuIds) {
        return roleService.update(role,menuIds);
    }
}
